package com.seu.dm.serviceimpls;

import com.seu.dm.entities.Favorite;
import com.seu.dm.mappers.FavoriteMapper;
import com.seu.dm.services.FavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by 张老师 on 2017/3/9.
 */
@Service
public class FavoriteServiceImpl implements FavoriteService{
    @Autowired
    private FavoriteMapper favoriteMapper;

    @Override
    public List<Favorite> findFavoritesByBuyerId(Integer buyerId) {
        return favoriteMapper.selectByBuyerId(buyerId);
    }

    @Override
    public int addNewFavorite(Favorite favorite) {
        return favoriteMapper.insert(favorite);
    }

    @Override
    public List<Favorite> findAllFavorites() {
        return favoriteMapper.selectAll();
    }

    @Override
    public int deleteFavoriteById(Integer id) {
        return favoriteMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int updateFavorite(Favorite favorite) {
        return favoriteMapper.updateByPrimaryKey(favorite);
    }

    @Override
    public Favorite findFavorite(Integer id) {
        return favoriteMapper.selectByPrimaryKey(id);
    }
}
